package com.googlecode.archimedes.filegen.model;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * <p>
 * A Class to handle creation of AbstractMethods on entities
 * </p>
 * 
 * <p>Created: Jul 22, 2005</p>
 * 
 * @author Erik Gustavson
 * @version $Id: AbstractMethod.java 553 2005-07-23 01:08:06 +0000 (Sat, 23 Jul 2005) erik $
 */
public class AbstractMethod extends AbstractAsset implements Comparable {

    private String name;
    private String returns;
    private String params;
    private String desc;

    /**
     * Returns the methodName.
     *
     * @return String value of methodName
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the methodName
     * @param methodName The methodName to set.
     */
    public void setName(String methodName) {
        this.name = methodName;
    }

    /**
     * Returns the params.
     *
     * @return String value of params
     */
    public String getParams() {
        return params;
    }

    /**
     * Sets the params
     * @param params The params to set.
     */
    public void setParams(String params) {
        this.params = params;
    }

    /**
     * Returns the returnValue.
     *
     * @return String value of returnValue
     */
    public String getReturns() {
        return returns;
    }

    /**
     * Sets the returnValue
     * @param returnValue The returnValue to set.
     */
    public void setReturns(String returnValue) {
        this.returns = returnValue;
    }

    /** 
     * @see com.tps.filegen.model.Asset#getSubordinateAssets()
     */
    public Collection<? extends Asset> getSubordinateAssets() {
        return new ArrayList<Asset>();
    }

    /**
     * Returns the desc.
     *
     * @return String value of desc
     */
    public String getDesc() {
        return desc;
    }

    /**
     * Sets the desc
     * @param desc The desc to set.
     */
    public void setDesc(String desc) {
        this.desc = desc;
    }

    /** 
     * @see java.lang.Comparable#compareTo(T)
     */
    public int compareTo(Object o) {
        AbstractMethod rhs = (AbstractMethod) o;
        AbstractMethod lhs = this;

        return rhs.compareTo(lhs);
    }

    /** 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {

        if (obj != null && obj instanceof AbstractMethod) {
            AbstractMethod other = (AbstractMethod) obj;
            return this.name.equals(other.name);
        }

        return false;
    }

    /** 
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(13, 7).append(name).toHashCode();
    }

}
